package com.godot.entity.checher;

import javax.jdo.PersistenceManager;

import com.godot.entity.persistent.Godot;

public class GodotChecher extends EntityUtil {

	public GodotChecher(PersistenceManager pm) {
		super(pm);
	}
	
	protected boolean checkGodotShouldNotExists(Godot godot) {
		if (godot != null) {
			return false;
		}
		return true;
	}
	
	protected boolean checkGodotNameAvailable(String name) {
		if (name.startsWith(" ") || name.endsWith(" ")) {
			return false;
		} else if (name.length() > 20) {
			return false;
		}
		return true;
	}
	
	protected boolean checkGodotShouldExist(Godot godot) {
		if (godot == null) {
			return false;
		}
		return true;
	}
	
	protected boolean checkGodotPasswordCorrect(Godot godot, String pwd) {
		return pwd.equals(godot.getPassword());
	}
	
	protected boolean checkGodotStatusShouldLogin(Godot godot) {
		return godot.getStatus() == Godot.kStatusNormal;
	}
	
	protected boolean checkGodotShouldLogin(Godot godot, String pwd) {
		if (!checkGodotShouldExist(godot)) {
			return false;
		}
		if (!checkGodotStatusShouldLogin(godot)) {
			return false;
		}
		if (!checkGodotPasswordCorrect(godot, pwd)) {
			return false;
		}
		return true;
	}

}
